package com.lucenten.mq;

import cn.quevo.common.lang.BooleanUtils;
import cn.quevo.common.lang.JSONUtils;
import cn.quevo.core.spring.util.PropertiesUtils;

import java.util.HashMap;
import java.util.Map;

public class SendJmsInfo {
    private final static PropertiesUtils propertiesUtils = new PropertiesUtils("/conf/gnss.properties");
    private final static String mQbrokerURL = propertiesUtils.getProperties("collect.mQbrokerURL");
    private final static String OPEN_MQ = propertiesUtils.getProperties("collect.openMq");
    public void sendInfo(String mQbrokerURL){
        try {
            if (!BooleanUtils.isTrue(OPEN_MQ)) {
                return;
            }
            MsgBusinessHandler.mQbrokerURL=mQbrokerURL;
            Map map = new HashMap();
            map.put("queueName","monitor");
            map.put("queuText","{index:\"test\",filename:\"asdfadsf.txt\"}");
          /*  String queueName =(String)map.get("queueName"); // 获取目标队列名称
            String queuText = (String)map.get("queuText"); // 获取目标队列名称*/
            MsgBusinessHandler.sendMsgToQueue(map);
            System.out.println("消息放入消息队列");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.out.println("消息放入消息队列出错");
            e.printStackTrace();

        }
    }

    public static void sendGnssMq(Integer key, String fileName, Integer result) {
        try {
            if (!BooleanUtils.isTrue(OPEN_MQ)) {
                return;
            }
            MsgBusinessHandler.mQbrokerURL=mQbrokerURL;
            Map<String,Object> queue = new HashMap<>();
            queue.put("queueName","monitor");
            Map<String,Object> map = new HashMap();
            map.put("system","collectInfo");
            map.put("key",key.toString());
            map.put("result", result.toString());
            map.put("ip","39.105.74.166");
            map.put("filename", fileName);
            queue.put("queuText", JSONUtils.format(map));
            MsgBusinessHandler.sendMsgToQueue(queue);
            System.out.println("消息放入消息队列");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.out.println("消息放入消息队列出错");
            e.printStackTrace();

        }
    }
    public static void sendGnssFileQty(Integer count) {
        try {
            if (!BooleanUtils.isTrue(OPEN_MQ)) {
                return;
            }
            MsgBusinessHandler.mQbrokerURL=mQbrokerURL;
            Map<String,Object> queue = new HashMap<>();
            queue.put("queueName","monitor");
            Map<String,Object> map = new HashMap();
            map.put("system","collectgnsscount");
            map.put("count", count);
//            map.put("key",key.toString());
//            map.put("result", result.toString());
//            map.put("ip","39.105.74.166");
//            map.put("filename", fileName);
            queue.put("queuText", JSONUtils.format(map));
            MsgBusinessHandler.sendMsgToQueue(queue);
            System.out.println("消息放入消息队列");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.out.println("消息放入消息队列出错");
            e.printStackTrace();

        }
    }

//    public static void main(String[] args) {
//        new SendJmsInfo().sendInfo("tcp://dev001.lucenten.com:61616");
//    }
}
